import 'package:flutter/material.dart';
import 'package:flutter_bsbdj/pagers/welcomePager.dart';

import 'interfaces/view_interface.dart';
import 'pagers/homePager.dart';
import 'utils/constant.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {

  // This widget is the root of your application.
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return MyAppWidget();
  }

}

class MyAppWidget extends State<MyApp>{

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    ThemeEvent.getInstance().registerEvent(this);
    Constant.getInstance().initTheme().then((value){
      setState(() {

      });
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: 'Flutter Demo',
//      theme: ThemeData(
//        primarySwatch: Colors.blue,
//      ),
      theme: Constant.getInstance().getTheme()?ThemeData.light():ThemeData.dark(),
      home: Welcome(),
    );
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    ThemeEvent.getInstance().unregister(this);
  }
}

